//
//  NWNetWorkingManager+QDMetro.m
//  ylh-app-primary-ios
//
//  Created by YueWen on 2018/12/4.
//  Copyright © 2018 巨商汇. All rights reserved.
//

#import "NWNetWorkingManager+QDMetro.h"

QDNetWorkingErrorKey *QDAppserviceHandlerError = @"QDAppserviceHandlerError";

@implementation NWNetWorkingManager (QDMetro)

+ (NSURLSessionDataTask *)qdRequestWithUrlString:(NSString *)urlString
                                            Method:(HTTPMethod)httpMethod
                                        Parameters:(NSDictionary *)parameters
                                           success:(NetWorkingSuccessBlock)successBlock
                                           failure:(NetWorkingFailureBlock)failureBlock {
    
    return  [self requestWithUrlString:urlString Method:httpMethod Parameters:parameters success:^(NSURLSessionDataTask *dataTask, NSDictionary *data) {
        
        if (![[data valueForKey:@"success"] boolValue]) {//表示出问题
            failureBlock(dataTask,[NSError errorWithDomain:[data valueForKey:@"message"] code:[[data valueForKey:@"code"] integerValue] userInfo:@{QDAppserviceHandlerError:@""}]); return;
        }
        
        successBlock(dataTask,data);

    } failure:^(NSURLSessionDataTask *dataTask, NSError *error) {
        failureBlock(dataTask,error);
    }];
}


@end
